package com.hqyj.hrms.modules.personnel.dao;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hqyj.hrms.modules.personnel.entity.*;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;


import java.util.HashMap;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zyj
 * @since 2021-09-27
 */
@Mapper
@Repository
@Component
public interface EmployeeMapper extends BaseMapper<Employee> {

    // 模糊查询
//    List<Employee> fuzzyQuery(Page<Employee> page, @Param("staff") Employee employee);
//@Select()
//    Employee query (String key1,String key2);
    @Select("SELECT emp_sex,COUNT(emp_sex) as count FROM employee as emp GROUP BY emp_sex")
    List<SexCount> querySexCount();

    @Update("update employee set emp_department =#{newDepartment} ,emp_job=#{newJob} where emp_id = #{empId}")
    void updateEmployee(Transfer transfer);

    @Select("SELECT emp_education,COUNT(emp_education)as count FROM employee  GROUP BY emp_education")
    List<EduCount> queryEduCount();

    @Select("SELECT e.age as emp_age,COUNT(age)AS count FROM(select (year(NOW())-year(emp_bir))as age from employee)e GROUP BY e.age")
    List<AgeCount> queryAgeCount();

}
